package com.course.server.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author: Durian
 * @date: 2021/5/1 22:20
 */
@Getter
public enum SectionChargeEnum {

    ERROR(999, "状态异常"),
    CHARGE(1, "收费"),
    FREE(0, "免费");

    private Integer code;
    private String desc;

    SectionChargeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SectionChargeEnum getCharge(Integer code) {
        for (SectionChargeEnum value : SectionChargeEnum.values()) {
            if (Objects.equals(code, value.code)) {
                return value;
            }
        }
        return ERROR;
    }


}
